package com.rzjm.exercise.common.log;

import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.stream.Collectors;

import com.rzjm.exercise.sys.core.log.domain.LogDO;

public enum LogQueue {
	INSTANCE;
	
	private Queue<LogDO> queue = new ConcurrentLinkedQueue<LogDO>();
	
	private LogQueue() {
	}
	
	public int size() {
		return queue.size();
	}
	
	public void clear() {
		queue.clear();
	}
	
	public LogDO poll() {
		return queue.poll();
	}
	
	public List<LogDO> pollList() {
		return queue.stream().map((s) -> queue.poll()).collect(Collectors.toList());
	}
	
	public void offer(LogDO sysLog) {
		queue.offer(sysLog);
	}
	
	public boolean isEmpty() {
		return queue.isEmpty();
	}
}
